'use strict';

module.exports = app => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;

  const CustomizeSchema = new Schema({
    id: {type: String},
    user_id: {type: String},
    type: {type: String}, // 自定义订阅类型: extract(智能订阅), weixin(微信公众号订阅), rss(RSS订阅)
    extract_url: {type: String},
    extract_board: {type: String},
    weixin_name: {type: String},
    weixin_code: {type: String},
    rss_url: {type: String},
    status: {type: Number, default: 0}, // 状态: 0(数据准备中), 1(已上线), -1(审批拒绝)
    avatar_url: {type: String},
    remark: {type: String}, // 备注
    inner_url: {type: String}, // 站内地址
  }, {timestamps: true});

  CustomizeSchema.index(
    {user_id: 1, type: 1, extract_url: 1, extract_board: 1, weixin_name: 1, rss_url: 1},
    {unique: true, background: true}
  );


  return mongoose.model('Customize', CustomizeSchema, 'customizes');
};
